package com.sys.platform.mapper;

import com.sys.platform.entity.DossierWarningUser;
import com.sys.platform.entity.request.dossierDeviceWarning.DossierDeviceWarningInfoDTO;
import com.sys.platform.entity.vo.SysUserVO;
import com.sys.platform.entity.vo.dossierDeviceWarning.DossierDeviceWarningVO;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.BaseMapper;
import tk.mybatis.mapper.common.IdsMapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;

/**
 * 档案馆设备告警Mapper接口
 *
 * @author yuanfuqiang
 * @date 2024-01-10
 */
public interface DossierWarningUserMapper extends BaseMapper<DossierWarningUser>, IdsMapper<DossierWarningUser>, MySqlMapper<DossierWarningUser> {

    @Select("SELECT * from sys_user ORDER BY create_time desc")
    List<SysUserVO> selectUserList();

    @Select("SELECT w.id, u.* from dossier_warning_user w LEFT JOIN sys_user u on w.user_id = u.user_id ORDER BY u.create_time desc")
    List<SysUserVO> userList();

    @Select("select * from dossier_device_warning where device_id = #{deviceId} and type = #{type} order by update_time desc LIMIT 1")
    DossierDeviceWarningVO selectDossierDeviceWarningInfo(DossierDeviceWarningInfoDTO dto);
}
